__author__ = 'lliugh'
# -*- coding: utf-8 -*-

# 读写2007 excel
# pip install openpyxl
import openpyxl

file_2003 = '/Users/liuguohao/workspace/python/data/2003.xls'
file_2007 = '/Users/liuguohao/workspace/python/data/2007.xlsx'

def write03Excel(path):
    wb = openpyxl.Workbook()
    sheet = wb.active
    sheet.title = "2003测试表"
    value = [["名称", "价格", "出版社", "语言"],
             ["如何高效读懂一本书", "22.3", "机械工业出版社", "中文"],
             ["暗时间", "32.4", "人民邮电出版社", "中文"],
             ["拆掉思维里的墙", "26.7", "机械工业出版社", "中文"]]
    for i in range(0, 4):
        for j in range(0, len(value[i])):
            sheet.cell(row=i+1, column=j+1, value=str(value[i][j]))
    wb.save(path)
    print("写入数据成功！")


def write07Excel(path):
    wb = openpyxl.Workbook()
    sheet = wb.active
    sheet.title = '2007测试表'

    value = [["名称", "价格", "出版社", "语言"],
             ["如何高效读懂一本书", "22.3", "机械工业出版社", "中文"],
             ["暗时间", "32.4", "人民邮电出版社", "中文"],
             ["拆掉思维里的墙", "26.7", "机械工业出版社", "中文"]]
    for i in range(0, 4):
        for j in range(0, len(value[i])):
            sheet.cell(row=i+1, column=j+1, value=str(value[i][j]))

    wb.save(path)
    print("写入数据成功！")


write03Excel(file_2003)

write07Excel(file_2007)
